﻿
@using Users.Models
@model RoleEditModel
@{
    ViewBag.Title = "编辑角色";
}
@Html.ValidationSummary()

@using (Html.BeginForm())
{
    <input type="hidden" name="roleName" value="@Model.Role.Name"/>
    <div class="panel panel-primary">
        <div class="panel-heading">
            向角色【 @Model.Role.Name】添加用户
        </div>
        <table class="table table-striped">
            @if (Model.NonMembers.Count() == 0)
            {
                <tr>
                    <td colspan="2">
                        暂无
                    </td>
                </tr>
            }
            else
            {
                <tr>
                    <td>用户名</td>
                    <td>添加至角色</td>
                </tr>
                foreach (AppUser user in Model.NonMembers)
                {
                    <tr>
                        <td>@user.UserName</td>
                        <td>
                            <input type="checkbox" name="IdsToAdd" value="@user.Id">
                        </td>
                    </tr>
                }
            }
        </table>
    </div>
    <div class="panel panel-primary">
        <div class="panel-heading">
            从角色【 @Model.Role.Name】移除用户
        </div>
        <table class="table table-striped">
            @if (Model.Members.Count() == 0)
            {
                <tr><td colspan="2">暂无</td></tr>
            }
            else
            {
                <tr>
                    <td>用户名</td>
                    <td>从角色中移除</td>
                </tr>
                foreach (AppUser user in Model.Members)
                {
                    <tr>
                        <td>@user.UserName</td>
                        <td>
                            <input type="checkbox" name="IdsToDelete" value="@user.Id">
                        </td>
                    </tr>
                }
            }
        </table>
    </div>
    <button type="submit" class="btn btn-primary">保存</button>
    @Html.ActionLink("取消", "Index", null, new { @class = "btn btn-default" })
}
